var empjsapi = '''
(function (win, undefined) {
    var doc = win.document;
    var emp = win.emp || (win.emp = {});
    var wx = win.wx || (win.wx = {});
    var success_prefix = "succ_";
    var error_prefix = "err_";
    var inc = 1;
    var callback = function (callable, param) {
        callable && callable(param);
    }
    var PersistenceFlag = 'Persistence';
    var requestFlag = 'requestFlag';
    var chooseFileFlag = 'chooseFileFlag';

    var Core = {
        call: function (cmd, params, success, failure) {
            var token = Private.getToken();
            if (cmd.indexOf('window.setTitle') > -1 || cmd.indexOf('optionMenu') > -1 || cmd.indexOf('setRightButton') > -1) {
                token = token + PersistenceFlag;
            }
            if (cmd.indexOf('request') > -1) {
                token = token + requestFlag;
            }
            if (cmd.indexOf('chooseFile') > -1) {
                token = token + chooseFileFlag;
            }
            if (!!success) {
                Private.callbackMap[success_prefix + token] = success;
            }
            if (!!failure) {
                Private.callbackMap[error_prefix + token] = failure;
            }

            window.Flutter.postMessage(JSON.stringify({
                cmd: cmd,
                token: token,
                data: params
            }));
        },
        fireEvent: function (eventName, parmas) {
            var e = doc.createEvent("HTMLEvents");
            e.initEvent(eventName, false, true);
            e.param = Private.parseParam(parmas);
            doc.dispatchEvent(e);
        },
        onSuccess: function (token, params) {
            callback(Private.callbackMap[success_prefix + token], params);
            Private.removeCallback(token);
        },
        onFailure: function (token, params, type) {
            callback(Private.callbackMap[error_prefix + token], {
                type: type,
                message: params.message || "",
                data: params
            })
            Private.removeCallback(token);
        },
        onNativeCall: function (command, data, callback) {
            var result = command(data);
            callback(result);
        },
        onReceiveAppMessage: function (message) {
            var type = message.type;
            if (message.token.indexOf(requestFlag) > -1) {
                message.data.result = JSON.parse(message.data.result)
            }
            if (message.token.indexOf(chooseFileFlag) > -1) {
                message.data.result = JSON.parse(message.data.result)
            }
            if (type.startsWith("result.")) {
                var data = message.data;
                if(data && typeof message.data.result === "object"){//因为happ的api都是json格式
                    data = data.result;
                    data.result = message.data.result;
                    //为了兼容，所以，以happ的json构建 result属性满足emp的格式
                }
                if (type === "result.success") {
                    Core.onSuccess(message.token, data);//没办法啊zzy
                } else {
                    Core.onFailure(message.token, data, type.substr(7));
                }
            } else if (type.startsWith("call.")) {
                Core.onNativeCall(type.substr(5), message.data, message.callback);
            } else {
                Core.fireEvent(type, message.data);
            }
        }
    };

    var Private = {
        getToken: function () {
            return Math.floor(Math.random() * (1 << 50)) + "" + inc++
        },
        parseParam: function (param) {
            if (str && typeof str === 'string') {
                try {
                    obj = JSON.parse(str);
                } catch (e) {
                    obj = eval("(" + str + ")");
                }
            } else {
                obj = str || {};
            }
            return obj;
        },
        removeCallback: function (token) {
            if (token.indexOf(PersistenceFlag) > -1) {

            } else {
                delete Private.callbackMap[success_prefix + token];
                delete Private.callbackMap[error_prefix + token];
            }
        },
        callbackMap: {}
    };
    for (var key in Core) {
        hasOwnProperty.call(emp, key) || (emp[key] = Core[key]);
    }

})(window);

function receiveAppMessage(message) {
    emp.onReceiveAppMessage(message);
}

emp.window = wx.window = {};
emp.addressBook = wx.addressBook = {};
emp.gestureUnlock = wx.gestureUnlock = {};
emp.touchID = wx.touchID = {};
emp.jinge = wx.jinge = {};
emp.face = wx.face = {};
emp.signature = wx.signature = {};
emp.video = wx.video = {};
emp.iapppdf = wx.iapppdf = {};
emp.device = wx.device = {};
emp.wps = wx.wps = {};
emp.badge = wx.badge = {};
emp.OAuth = wx.OAuth = {};
emp.quanshi = wx.quanshi = {};
emp.hst = wx.hst = {};
emp.mt = wx.mt = {};
emp.conversation = wx.conversation = {};
emp.im = wx.im = {};
emp.ca = wx.ca = {};
 
// 判断当前客户端版本是否支持指定JS接口
emp.checkJsApi = wx.checkJsApi = function (params) {
    var data = {
        jsApiList: params.jsApiList || []
    };
    emp.call("checkJsApi", data, params.success, params.error);
};

// 2. 相机功能

// 2.1 拍照或者从相册选择
emp.chooseImage = wx.chooseImage = function (params) {
    var data = {
        count: params.count || 1,
        sizeType: params.sizeType || ['original', 'compressed'],
        sourceType: params.sourceType || ['album', 'camera'],
        defaultCameraMode: params.defaultCameraMode || 'normal',
        isSaveToAlbum: params.isSaveToAlbum == null ? 1 : params.isSaveToAlbum
    };
    emp.call("chooseImage", data, params.success, params.error);
};

emp.getLocalImgData = wx.getLocalImgData = function (params) {
    var data = {
        localId: params.localId
    }
    emp.call("getLocalImgData", data, params.success, params.error);
};

// 2.2 预览图片
emp.previewImage = wx.previewImage = function (params) {
    var data = {
        current: params.current,
        urls: params.urls || []
    };
    emp.call("previewImage", data, params.success, params.error);
};

// 2.3 上传图片
emp.uploadImage = wx.uploadImage = function (params) {
    var data = {
        localId: params.localId,
        isShowProgressTips: params.isShowProgressTips
    };
    emp.call("uploadImage", data, params.success, params.error);
};

// 2.4 下载图片
emp.downloadImage = wx.downloadImage = function (params) {
    var data = {
        serverId: params.serverId,
        isShowProgressTips: params.isShowProgressTips
    };
    emp.call("downloadImage", data, params.success, params.error);
};

// 3. 录音/音频
// 3.1 开始录音
emp.startRecord = wx.startRecord = function (params) {
    var data = {};
    emp.call("startRecord", data, params.success, params.error);
};

// 3.2 停止录音
// 停止录音    
emp.stopRecord = wx.stopRecord = function (params) {
    var data = {};
    emp.call("stopRecord", data, params.success, params.error);
};

// 3.3 监听录音自动停止
// 监听录音自动停止接口
// 在移动门户H5微信应用容器中，录音时间长度限制视系统设置而定，不一定是一分钟。    
emp.onVoiceRecordEnd = wx.onVoiceRecordEnd = function (params) {
    // 录音时间超过一分钟没有停止的时候会执行 complete 回调
    var data = {};
    emp.call("onVoiceRecordEnd", data, params.complete, params.error);
};

// 3.4 播放语音接口
// 播放语音接口
emp.playVoice = wx.playVoice = function (params) {
    var data = {
        localId: params.localId, // 需要播放的音频的本地ID，由stopRecord接口获得
    };
    emp.call("playVoice", data, params.success, params.error);
};

// 3.5 暂停播放接口
// 暂停播放接口
emp.pauseVoice = wx.pauseVoice = function (params) {
    var data = {
        localId: params.localId, // 需要播放的音频的本地ID，由stopRecord接口获得
    };
    emp.call("pauseVoice", data, params.success, params.error);
}

// 3.6 停止播放接口
// 停止播放接口
emp.stopVoice = wx.stopVoice = function (params) {
    var data = {
        localId: params.localId, // 需要播放的音频的本地ID，由stopRecord接口获得
    };
    emp.call("stopVoice", data, params.success, params.error);
};

// 3.7 监听语音播放完毕
// 监听语音播放完毕接口
emp.onVoicePlayEnd = wx.onVoicePlayEnd = function (params) {
    var data = {};
    emp.call("onVoicePlayEnd", data, params.success, params.error);
};

// 3.8 上传语音接口
emp.uploadVoice = wx.uploadVoice = function (params) {
    var data = {
        localId: params.localId, // 需要上传的音频的本地ID，由stopRecord接口获得
        isShowProgressTips: params.isShowProgressTips || 1, // 默认为1，显示进度提示
    };
    emp.call("uploadVoice", data, params.success, params.error);
};

// 3.9 下载语音接口    
emp.downloadVoice = wx.downloadVoice = function (params) {
    var data = {
        serverId: params.serverId, // 需要下载的音频的服务器端ID，由uploadVoice接口获得
        isShowProgressTips: params.isShowProgressTips || 1, // 默认为1，显示进度提示
    };
    emp.call("downloadVoice", data, params.success, params.error);
};

// 4. 获取设备信息功能
// 4.1 获取设备网络状态
emp.getNetworkType = wx.getNetworkType = function (params) {
    var data = {};
    emp.call("getNetworkType", data, params.success, params.error);
};
 
// 4.2 获取设备信息
emp.device = wx.device = function (params) {
    var data = {};
    emp.call("device", data, params.success, params.error);
};

// 5. 地理位置
// 5.1 返回当前位置经纬度
emp.getLocation = wx.getLocation = function (params) {
    var data = {
        type: params.type || 'wgs84', // 默认为wgs84的gps坐标
    };
    emp.call("getLocation", data, params.success, params.error);
};

// 5.2 内置地图查看位置
emp.openLocation = wx.openLocation = function (params) {
    var data = {
        type: params.type || 'bd09', // 默认为 bd09 的百度坐标
        latitude: params.latitude || 0, // 纬度，浮点数，范围为90 ~ -90
        longitude: params.longitude || 0, // 经度，浮点数，范围为180 ~ -180。
        name: params.name || '', // 位置名
        address: params.address || '', // 地址详情说明
        scale: params.scale || 21, // 地图缩放级别,整形值,范围从1~28。默认为最大 百度地图在手机上当前可使用的级别为3-21级
        infoUrl: params.infoUrl || '' // 在查看位置界面底部显示的超链接,可点击跳转
    };
    emp.call("openLocation", data, params.success, params.error);
};


// 6. ibeacon
// 6.1 开启查找周边ibeacon设备

// 6.2 关闭查找周边ibeacon设备

// 6.3 监听周边ibeacon设备接口

// 7. 扫描功能
// 7.1 二维码扫描
emp.scanQRCode = wx.scanQRCode = function (params) {
    var data = {
        needResult: params.needResult || 0,
        scanType: params.scanType || ["qrCode", "barCode"]
    };
    emp.call("scanQRCode", data, params.success, params.error);
};

// 8 身份验证
// 8.1 手势验证

emp.gestureUnlock.isGestureCodeSet = wx.gestureUnlock.isGestureCodeSet = function (params) {
    var data = {};
    emp.call("gestureUnlock.isGestureCodeSet", data, params.success, params.error);
};

// 8.1.2 手势验证
emp.gestureUnlock.verify = wx.gestureUnlock.verify = function (params) {
    var data = {};
    emp.call("gestureUnlock.verify", data, params.success, params.error);
};

// // 8.2 指纹验证
// 8.2.1 是否支持指纹
emp.touchID.canAuthenticate = wx.touchID.canAuthenticate = function (params) {
    var data = {};
    emp.call("touchID.canAuthenticate", data, params.success, params.error);
};

// // 8.2.2 指纹验证s
emp.touchID.authenticate = wx.touchID.authenticate = function (params) {
    var data = {
        mode: params.mode || 1
    };
    emp.call("touchID.authenticate", data, params.success, params.error);
};

// // 8.3 人脸识别
// 8.3.1 查询人脸识别是否可用
emp.face.recognition = wx.face.recognition = function (params) {
    var data = {};
    emp.call("face.recognition", data, params.success, params.error);
};

// 8.3.2 人脸识别开启
emp.face.open = wx.face.open = function (params) {
    var data = {};
    emp.call("face.open", data, params.success, params.error);
};
 
// 8.3.3 人脸识别活体验证
emp.face.liveVerify = wx.face.liveVerify = function (params) {
    var data = {};
    emp.call("face.liveVerify", data, params.success, params.error);
};

// 8.3.4 人脸识别打卡签到
emp.face.punchCard = wx.face.punchCard = function (params) {
    var data = {
        userName: params.userName,
        address: params.address
    };
    emp.call("face.punchCard", data, params.success, params.error);
};

// 8.4 授权
// 8.4.1 获取授权应用的子账号
emp.OAuth.getSubAccountId = wx.OAuth.getSubAccountId = function (params) {
    var data = {
    appId: params.appId,
    type: params.type
    };
    emp.call("OAuth.getSubAccountId", data, params.success, params.error);
};
 
// 8.4.2 获取授权信息
emp.OAuth.getAuthToken = wx.OAuth.getAuthToken = function (params) {
    var data = {
        appId: params.appId,
        subAccountId: params.subAccountId || "",            // 需授权应用的子账号，可为空
        type: params.type
    };
    emp.call("OAuth.getAuthToken", data, params.success, params.error);
};

// 9. 通讯录
// 9.1 通讯录选人
emp.addressBook.choose = wx.addressBook.choose = function (params) {
    var data = {
        startWithDepartmentId: params.startWithDepartmentId || 0,
        multiple: params.multiple,
        users: params.users || [],
        disabledUsers: params.disabledUsers || [],
        corpId: params.corpId || 0,
        max: params.max || 500,
        limitTips: params.limitTips || "当前选择人数已超过最大值",
        isNeedSearch: params.isNeedSearch,
        title: params.title || "选择联系人",
        local: params.local
    };
    emp.call("addressBook.choose", data, params.success, params.error);
};

// 10. 文件下载
// 10.1 本地文件访问

// 10.2 文件下载到App中
emp.downloadFileIntoApp = wx.downloadFileIntoApp = function (params) {
    var data = {
        taskid: params.taskid, //下载标识，将原样返回给毁掉函数，便于回调函数判断
        url: params.url, //文件下载路径
    };
    emp.call("downloadFileIntoApp", data, params.success, params.error)
};

// 10.3 调用系统功能下载文件
emp.downloadFileBySystem = wx.downloadFileBySystem = function (params) {
    var data = {
        taskid: params.taskid, //下载标识，将原样返回给毁掉函数，便于回调函数判断
        url: params.url, //文件下载路径
    };
    emp.call("downloadFileBySystem", data, params.success, params.error)
};

// 10.4 调用系统应用打开下载的文件

// 10.5 文件预览
emp.docPreview = wx.docPreview = function (params) {
    var data = {
        downloadUrl: params.downloadUrl || '', // 文件下载的http链接
        convertType: params.convertType || '' // 可选参数, 默认 word->pdf; excle->html
    };
    emp.call("docPreview", data, params.success, params.error)
};

// 11. 窗口操作
// 11.1	打开一个新的窗口
emp.window.open = wx.window.open = function (params) {
    var data = {
        id: params.id || '', // 窗口标识,如果该标识窗口已经打开,则显示出来，如果没有就创建一个新H5应用容器，再显示出来
        title: params.title || '', //窗口标题
        dataType: params.dataType || 0, //窗口填充数据类型, 0: url, 1:数据,
        data: params.data || '', //窗口填充的数据, dataType=0 是远程加载地址url， datatype=1时是HTML内容
        target: params.target || '', //指定的显示区域，该参数只有在屏幕上有多个显示区域时起作用，目前主要用于Pad版
    };
    emp.call("window.open", data, params.success, params.error);
};

// // 11.2	关闭窗口
// // 关闭指定的H5容器，
emp.window.close = wx.window.close = function (params) {
    if(!params){//缺省值的处理
        params = {};
    }
    var data = {
        id: params.id || 'this', //指定被关闭窗口标识，如果id=‘this‘，则关闭当前窗口
    };
    emp.call("window.close", data, params.success, params.error);
};
 


// // 11.3	打开一个悬浮窗口/ 弹出框
// // 打开一个悬浮h5应用容器窗口，区别于普通H5应用容器，它可以被指定长宽，以及屏幕上显示位置，可以看做一个可指定内容的对话框。
emp.window.openPopover = wx.window.openPopover = function (params) {
    var data = {
        id: params.id || '', // 窗口标识,如果该标识窗口已经打开,则显示出来，如果没有就创建一个新H5应用容器，再显示出来
        title: params.title || '', //窗口标题
        dataType: params.dataType || 0, //窗口填充数据类型, 0: url, 1:数据,
        data: params.data || '', //窗口填充的数据, dataType=0 是远程加载地址url， datatype=1时是HTML内容
        width: params.width || '', //窗口宽度
        height: params.height || '', //窗口高度
        left: params.left || '', //弹出框距离左边的距离
        top: params.top || '', //弹出框距离上边的距离
    };
    emp.call("window.openPopover", data, params.success, params.error);
};

// // 11.4	关闭悬浮窗口/ 弹出框
// // 关闭指定的H5悬浮窗口，如果指定id对应的的不是悬浮窗口，将被忽略。
emp.window.closePopover = wx.window.closePopover = function (params) {
    var data = {
        id: params.id || '', //指定被关闭popover窗口标识，如果id=‘this‘，则关闭当前窗口
    };
    emp.call("window.closePopover", data, params.success, params.error);
};

// // 11.5	弹出一个警告窗口
// // 打开一个警告（Alert）窗口，用于替换H5应用容器默认的alert窗口，默认Alert窗口的title会显示当前H5应用容器加载的网页加载地址。警告框只有一个“确认”按钮。
emp.window.alert = wx.window.alert = function (params) {
    var data = {
        title: params.title || '', //窗口标题文字
        content: params.content || '', //警告框要显示的文本内容
        button: params.button || '', //按钮上显示的按钮名字
    };
    emp.call("window.alert", data, params.success, params.error);
};

// // 11.6	弹出一个确认窗口
emp.window.confirm = wx.window.confirm = function (params) {
    var data = {
        title: params.title,
        content: params.content,
        buttons: params.buttons
    };
    emp.call("window.confirm", data, params.success, params.error);
};

// // 11.7	弹出一个可以输入内容的提示窗口
emp.window.alertInput = wx.window.alertInput = function (params) {
    var data = {
        title: params.title || '', //窗口标题文字
        content: params.content || '', //窗口中显示文本内容
        defaultValue: params.defaultValue || '',//输入框中默认输入值
        buttons: params.buttons || ['取消', '确定'], //按钮名称数组，内容为按钮名称
    };
    emp.call("window.alertInput", data, params.success, params.error);
};

// // 11.8	刷新指定窗口
// // 刷新指定窗口，重新载入该窗口当前的url。
emp.window.refresh = wx.window.refresh = function (params) {
    var data = {
        id: params.id || 'this', //窗口id
    };
    emp.call("window.refresh", data, params.success, params.error);
};

// 12. 界面功能
// 12.1 保留当前页面跳转
emp.navigateTo = wx.navigateTo = function (params) {
    var data = {
        url: params.url
    };
    emp.call("navigateTo", data, params.success, params.error);
};

// 12.2 关闭当前页面跳转
emp.redirectTo = wx.redirectTo = function (params) {
    var data = {
        url: params.url
    };
    emp.call("redirectTo", data, params.success, params.error);
};

// 12.3 关闭当前页面回退前一页
emp.navigateBack = wx.navigateBack = function () {
    var data = {};
    emp.call("navigateBack", data, params.success, params.error);
};


// 13. 标题栏设置
// 13.1 设置标题栏内容
// 只允许设置中间和右边内容

emp.window.setTitle = wx.window.setTitle = function (params) {
    var data = {
        title: params.title,
        rightMenu: params.rightMenu
    };
    emp.call("window.setTitle", data, params.titleaction, params.rightmenuaction);
};

// // 13.2 菜单按钮
// // 设置菜单中的菜单项按钮

emp.optionMenu = wx.optionMenu = function (params) {
    var data = {
        menuSite: params.menuSite || 'middle',
        button: params.button || [],
    };
    emp.call("optionMenu", data, params.callback, params.error);
};

// 14. IM 消息想·
// 14.1 创建本地 IM 会话，并跳转至会话窗口
emp.createImSession = wx.createImSession = function (params) {
    var data = {
        type: params.type,
        groupId: params.groupId,
        id: params.id || '',
        name: params.name
    };
    emp.call("createImSession", data, params.success, params.error);
};

// 15.金格插件
emp.jinge.openWebFile = wx.jinge.openWebFile = function (params) {
    var data = {
        hostUrl: params.hostUrl,
        fileId: params.fileId,
        isPGFFormat: params.isPGFFormat,
        readOnly: params.readOnly,
        userName: params.userName,
        enterReviseMode: params.enterReviseMode,
        isScreenshotForbid: params.isScreenshotForbid
    };
    emp.call("openWebFile", data, params.success, params.error);
};
 
emp.iapppdf.openWebPdfFile = wx.iapppdf.openWebPdfFile = function (params) {
    var data = {
        fileUrl: params.fileUrl,
        uploadUrl: params.uploadUrl,
        uploadParams: params.uploadParams,
        readOnly: params.readOnly,
        userName: params.userName,
        viewMode: params.viewMode
    };
    emp.call("openWebPdfFile", data, params.success, params.error);
};

emp.request = wx.request = function (params) {
    var data = {
        url: params.url || ''
    };
    if (!!params.body) {
        data.body = JSON.stringify(params.body);
    }
    emp.call("request", data, params.success, params.error);
};

emp.openRemoteFile = wx.openRemoteFile = function (params) {
    var data = {
        name: params.name,
        type: params.type,
        size: params.size,
        md5: params.md5,
        fileUrl: params.fileUrl
    };
    emp.call("openRemoteFile", data, params.success, params.error);
};

// 16.水印
emp.waterMark = wx.waterMark = function (params) {
    var data = {
        content: params.content
    };
    emp.call("waterMark", data, params.success, params.error);
};

// 17. 手写签名
// 17.1 手写签名获取
emp.signature.get = wx.signature.get = function (params) {
    var data = {};
    emp.call("signature.get", data, params.success, params.error);
};

// 17.2 手写签名更改
emp.signature.update = wx.signature.update = function (params) {
    var data = {};
    emp.call("signature.update", data, params.success, params.error);
};

// 17.3 手写签名打开
emp.signature.open = wx.signature.open = function (params) {
    var data = {};
    emp.call("signature.open", data, params.success, params.error);
};

emp.video.record = wx.video.record = function (params) {
    var data = {};
    emp.call("video.record", data, params.success, params.error);
};

emp.video.play = wx.video.play = function (params) {
    var data = {
        localId: params.localId
    };
    emp.call("video.play", data, params.success, params.error);    
};

emp.video.upload = wx.video.upload = function (params) {
    var data = {
        localId: params.localId
    };
    emp.call("video.upload", data, params.success, params.error);
};

// 24.1 蓝牙
// 24.1.1 初始化蓝牙模块
emp.openBluetoothAdapter = wx.openBluetoothAdapter = function (params) {
    var data = {};
    emp.call("openBluetoothAdapter", data, params.success, params.error);
};
 
// 24.1.2 关闭蓝牙模块
emp.closeBluetoothAdapter = wx.closeBluetoothAdapter = function (params) {
    var data = {};
    emp.call("closeBluetoothAdapter", data, params.success, params.error);
};
 
// 24.2 iBeacon
// 24.2.1 开始搜索附近的 iBeacon 设备
emp.startBeaconDiscovery = wx.startBeaconDiscovery = function (params) {
    var data = {
        uuids: params.uuids
    };
    emp.call("startBeaconDiscovery", data, params.success, params.error);
};
 
// 24.2.2 停止搜索附近的 iBeacon 设备
emp.stopBeaconDiscovery = wx.stopBeaconDiscovery = function (params) {
    var data = {};
    emp.call("stopBeaconDiscovery", data, params.success, params.error);
};
 
// 24.2.3 获取所有已搜索的 iBeacon 设备
emp.getBeacons = wx.getBeacons = function (params) {
    var data = {};
    emp.call("getBeacons", data, params.success, params.error);
};
 
// 24.2.4 监听 iBeacon 设备的更新事件
emp.onBeaconUpdate = wx.onBeaconUpdate = function (params) {
    var data = {};
    emp.call("onBeaconUpdate", data, params.success, params.error);
};
 
// 24.2.5 监听 iBeacon 服务的状态变化
emp.onBeaconServiceChange = wx.onBeaconServiceChange = function (params) {
    var data = {};
    emp.call("onBeaconServiceChange", data, params.success, params.error);
};
 
emp.openVoiceAssistant = wx.openVoiceAssistant = function () {
    var data = {};
    var success = function(){};
    var fail = function(){};
    emp.call("openVoiceAssistant", data, success, fail);
};

emp.chooseFile = wx.chooseFile = function (params) {
    var data = {
        url: params.url,
        type: params.type
    };
    emp.call("chooseFile", data, params.success, params.error);
};

emp.wps.editOnlineFileById = wx.wps.editOnlineFileById = function (params) {
    var data = {
        uploadUrl: params.uploadUrl,
        downloadUrl: params.downloadUrl,
        fileId: params.fileId,
        enterReviseMode: !!params.enterReviseMode,
        userName: params.userName || '',
        showReviewingPaneRightDefault: !!params.showReviewingPaneRightDefault,
        enterEditMode: !!params.enterEditMode,
        isScreenshotForbid: !!params.isScreenshotForbid,
        keepLocal: !!params.keepLocal
    };
    emp.call("wps.editOnlineFileById", data, params.success, params.error);
};

emp.badge.setBadge = wx.badge.setBadge = function (params) {
    var data = {
        count: params.count
    };
    emp.call("badge.setBadge", data, params.success, params.error);
};

emp.window.setRightButton = wx.window.setRightButton = emp.setRightButton = wx.setRightButton = function (params) {
    var data = {
        icon: params.icon,
        url: params.url,
        title: params.title || params.text || ''
    };
    emp.call("setRightButton", data, params.success, params.error);
};

emp.quanshi.openQuanshiMeeting = wx.quanshi.openQuanshiMeeting = function (params) {
    var  data = {
        userId: params.userId || '',
        username: params.username || '',
        meetingId: params.meetingId || '',
        meetingCode: params.meetingCode || ''
    };
    emp.call("quanshi.openQuanshiMeeting", data, params.success, params.error);
};

emp.setStorage = wx.setStorage = function (params) {
    var data = {
        key: params.key || '',
        data: params.data || ''
    };
    emp.call("setStorage", data, params.success, params.error);
};
 
emp.getStorage = wx.getStorage = function (params) {
    var data = {
        key: params.key || ''
    };
    emp.call("getStorage", data, params.success, params.error);
};
 
emp.removeStorage = wx.removeStorage = function (params) {
    var data = {
        key: params.key || ''
    };
    emp.call("removeStorage", data, params.success, params.error);
};
 
emp.setGlobalStorage = wx.setGlobalStorage = function (params) {
    var data = {
    key: params.key || '',
    data: params.data || ''
    };
    emp.call("setGlobalStorage", data, params.success, params.error);
};

emp.getGlobalStorage = wx.getGlobalStorage = function (params) {
    var data = {
    key: params.key || ''
    };
    emp.call("getGlobalStorage", data, params.success, params.error);
};

emp.removeGlobalStorage = wx.removeGlobalStorage = function (params) {
    var data = {
    key: params.key || ''
    };
    emp.call("removeGlobalStorage", data, params.success, params.error);
};
 
emp.clearStorage = wx.clearStorage = function (params) {
    var data = {};
    emp.call("clearStorage", data, params.success, params.error);
};

emp.hst.enterMeeting = wx.hst.enterMeeting = function (params) {
    var data = {
        type: params.type || 1,
        roomId: params.roomId || '',
        serverIp: params.serverIp || '',
        serverPort: params.serverPort || '',
        roomPwd: params.roomPwd || '',
        nickName: params.nickName || '',
        userName: params.userName || '',
        password: params.password || ''
    };
    emp.call("hst.enterMeeting", data, params.success, params.error);
};

 emp.mt.enterMeeting = wx.mt.enterMeeting = function (params) {
    var data = {
        type: params.type || 1,
        roomId: params.roomId || '',
        meetingName : params.meetingName || '',
        audio: params.audio,
        video: params.video,
        userName: params.userName || '',
        role: params.role || 0
    };
    emp.call("mt.enterMeeting", data, params.success, params.error);
};

emp.conversation.share = wx.conversation.share = function (params) {
    var data = {};
    emp.call("conversation.share", data, params.success, params.error);
};

emp.im.sendCardMessage = wx.im.sendCardMessage = function (params) {
    var data = params;
    emp.call("im.sendCardMessage", data, params.success, params.error);
}

emp.im.selectMembers = wx.im.selectMembers = function (params) {
    var data = params;
    emp.call("im.selectMembers", data, params.success, params.error);
}

emp.im.conversationInfo = wx.im.conversationInfo = function (params) {
    var data = params;
    emp.call("im.conversationInfo", data, params.success, params.error);
}

emp.im.createMeeting = wx.im.createMeeting = function (params) {
    var data = params;
    emp.call("im.createMeeting", data, params.success, params.error);
}
emp.im.sendFileMessages = emp.sendFileMessages = function (params) {
    var data = params;
    emp.call("sendFileMessages", data, params.success, params.error);
}
 
emp.requestAuthCode = emp.im.requestAuthCode = wx.requestAuthCode = function (params){
    var data = params;
    emp.call("requestAuthCode", data, params.onSuccess, params.onFail);
}

emp.ca.auth = wx.ca.auth = function (params) {
    var data = params;
    emp.call('ca.auth',data, params.success, params.error);
}

 emp.ca.test = wx.ca.auth = function (params) {
     var data = params;
     emp.call('ca.test',data, params.success, params.error);
 }
 
window.cocall = emp;

(function (win, doc) {
    if(win.onEmpReady){
        win.onEmpReady();
    }else{
        const event = doc.createEvent("HTMLEvents");
        event.initEvent("onEmpReady", true, true);
        doc.dispatchEvent(event);
    }
})(window, document);
''';
